(function(app){
	app
		.controller("content_21_checkCtrl",["$scope","myFactory",'$http','$stateParams','$state','$location','$ionicHistory',function($scope,myFactory,$http,$stateParams,$state,$location,$ionicHistory){
			//接收参数
			var chdrnum01 =  $stateParams.chdrnum01; //保单号
			var chdrcoy = $stateParams.chdrcoy; //保单公司号码
			var state = $stateParams.state;//获得跳转过来的路由
			var policyData;//保单详情
			var _productType ="";//产品类型，定义为全局变量方便使用
			var token=sessionStorage.getItem("token");
			//绑定到页面
			$scope.chdrnum01 = $stateParams.chdrnum01;
			$scope.showFlag = true; //控制前端是否显示“详情、重审、退出”三个功能，默认显示
			$scope.item21 = $stateParams.item21;
			$scope.investDiv21CheckFlag = false;//	投连区域
			$scope.universalDiv21CheckFlag = false;//	万能区域
			if($scope.item21.accountList!=undefined && $scope.item21.accountList!=null && $scope.item21.accountList!=""){
				for(var i=0;i<$scope.item21.accountList.length;i++){
					$scope.item21.accountList[i].accountDesc=$scope.item21.accountList[i].accountDesc.replace("投资账户","");
				}
			}

/**********************************************初始化内容begin************************************************/
			_productType = $scope.item21.productType;	//	产品类型，作为全局变量在开头已经定义
			
			//	存在投连产品时显示
			if( _productType.indexOf("U") > -1 ){
				//$("#showContentFor21Check").html("本变更项预计应退金额（元）"); 
				$scope.item21.itemFee.showContent = "本变更项预计应退金额（元）";
				//	取消隐藏
				$scope.investDiv21CheckFlag = true;
			}
			//	存在万能产品时显示		
			if( _productType.indexOf("W") > -1 ){
				$scope.universalDiv21CheckFlag = true;
			}
/**********************************************初始化内容end************************************************/	
			//重新受理
			$scope.renew = function(){
				myFactory.renew();
			}
			//退出移动保全
			$scope.exit = function(){
				myFactory.exit();
			}
			//返回函数
			$scope.goBack = function () {
				myFactory.goBack();
			}
			//保单详情弹窗
			$scope.showPolicyDetail = function(){
				modal('open','policyModalOn21Check','overwindowOn21Check','policyCloseXOn21Check');
				var timestamp=myFactory.getTimetamp();
				var sfis= "chdrnum-chdrcoy-token-timestamp";
				var signStr="chdrnum="+chdrnum01+"&chdrcoy="+chdrcoy+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				//查询保单详情
				$http({
					method: 'GET',
					url: app.domain + 'query/restFindPolicyDetail.action',
					params: {'chdrnum': chdrnum01,'chdrcoy': chdrcoy,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						policyData = response.data.data;
						$scope.policyData = policyData;
						$scope.policyData.ptdate01=myFactory.DateTools($scope.policyData.ptdate01);
					}
				}, function errorCallback(response) {
					myFactory.alert("","初始化查询订单详情失败!","info");
				});
			}
			
			//保单详情弹窗关闭函数
			$scope.policyCancelOn17Check = function(){
				modal('close','policyModalOn21Check','overwindowOn21Check','policyCloseXOn21Check');
			}
			//关闭遮罩
			$scope.overwindowClose = function(){
				//$(".overwindow").show();
				$(".overwindow").hide();
				$(".overmodal").hide();
			}
			//根据路由判断是否要显示详情、重新受理、退出三个功能
			if("history_detail"==state){
				$scope.showFlag = false;//不显示
			}	
		}]);  
		//指针弹窗
		app.directive('infoid',function(){
			return {
				restrict: 'EA',		//指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
				templateUrl: 'html/input/content_base_info.html'+app.clearCache,
				replace: true,		//设置解析后，DOM声明的指令是否消失
				link: function(scope,element,attrs){  //链接函数负责注册DOM事件和更新DOM,
					console.log('指令完成');
				}
			}
		});
})(app)